package com.popo.android;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.popo.android.widget.MyFrameLayout;
import com.popo.android.widget.MyTurnAdapterLayout;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class TestLayout extends Activity {
	Cursor cursor;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.framelayouttest);
		AdapterView<Adapter> myTurnAdapterLayout =  (AdapterView<Adapter>) findViewById(R.id.turnadapterlayout);
//		ListView myTurnAdapterLayout = (ListView) findViewById(R.id.turnadapterlayout);
		MyAdapter simpleAdapter = new MyAdapter(this, getData(), R.layout.main, new String[]{"t"}, new int[]{R.id.mytesttext});
		myTurnAdapterLayout.setAdapter(simpleAdapter);
		System.out.println("R.id.mytesttext="+R.id.mytesttext+","+R.id.maina);
	}

	private List<? extends Map<String, ?>> getData() {
		// TODO Auto-generated method stub
		ArrayList<Map<String, String>> list = new ArrayList<Map<String,String>>();
		Map<String,String> item1 = new HashMap<String ,String>();
		item1.put("t", "version....");
		list.add(item1);
		
		return list;
	}

	private void stop() {
		// TODO Auto-generated method stub
		stopManagingCursor(cursor);
		Log.v("msg","stop");
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		Log.v("msg","onDestroy");
		super.onDestroy();
//		android.os.Debug.stopMethodTracing();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		Log.v("msg","onPause");
		super.onPause();
	}

	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
		Log.v("msg","onRestart");
		super.onRestart();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		Log.v("msg","onResume");
		super.onResume();
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		Log.v("msg","onStart");
		super.onStart();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		Log.v("msg","onStop");
		super.onStop();
	}
	
	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
	
		super.onBackPressed();
		Log.v("msg","onBackPressed");
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		return super.onTouchEvent(event);
	}
}

class MyAdapter extends SimpleAdapter{

	public MyAdapter(Context context, List<? extends Map<String, ?>> data,
			int resource, String[] from, int[] to) {
		super(context, data, resource, from, to);
		// TODO Auto-generated constructor stub
	}
	
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		return super.getView(position, convertView, parent);
	}
}

